package com.sky.myapplication.kotlin.kotlinActivity

import android.Manifest
import android.app.Activity
import android.os.AsyncTask
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.sky.myapplication.R
import com.sky.myapplication.java.data.VideoEntity
import com.sky.myapplication.java.utils.FileUtil
import com.sky.myapplication.java.utils.VIdeoUtil
import com.sky.myapplication.kotlin.`class`.DataPersonKotlin
import com.sky.myapplication.kotlin.`class`.InterfacePersonKotlin
import com.sky.myapplication.kotlin.`class`.PersonKotlin
import com.sky.myapplication.kotlin.`class`.StudentKotlin
import pub.devrel.easypermissions.EasyPermissions
import java.lang.IllegalArgumentException

/**
 * Created by Min
 * Time 2023/2/8
 * Desc
 */
class VideoKotlinActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_video)

        if (EasyPermissions.hasPermissions(this, Manifest.permission.READ_EXTERNAL_STORAGE)){
            var videoTask = VideoTask()
            videoTask.execute()
        } else {
            EasyPermissions.requestPermissions(this, "", 123, Manifest.permission.READ_EXTERNAL_STORAGE);
        }
    }

    inner class VideoTask : AsyncTask<String, Int, List<VideoEntity>>(){

        override fun doInBackground(vararg params: String?): List<VideoEntity> {
//            return VIdeoUtil.init(this@VideoKotlinActivity)
            return FileUtil.getAllText(this@VideoKotlinActivity)
        }

        override fun onPostExecute(result: List<VideoEntity>?) {
            super.onPostExecute(result)
            Log.i("mxp", result.toString())
//            var fileList = ArrayList<String>()
//            for (entity in result!!){
//                if ((entity.filePath.endsWith(".docx") || entity.filePath.endsWith(".xls") || entity.filePath.endsWith(".pdf")) && !fileList.contains(entity.filePath)){
//                    fileList.add(entity.filePath)
//                }
//            }
//            Log.i("mxp", fileList.toString())
        }
    }
}